package cn.iocoder.yudao.module.api.promotion.coupon.dto;

import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.validation.Percent;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "优惠劵模板 Response DTO")
@Data
public class CouponTemplateRespDTO {

    @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "店铺编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    private Long shopId;

    @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送")
    private String name;

    @Schema(description = "发行总量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // -1 - 则表示不限制发放数量
    private Integer totalCount;

    @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制
    private Integer takeLimitCount;

    @Schema(description = "领取方式：1-直接发放、2-指定发放、3-新人券", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer takeType;

    @Schema(description = "是否设置满多少金额可用，单位：分，0表示不限制", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
    private Integer usePrice;

    @Schema(description = "生效日期类型：1-固定日期、2-领取日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer validityType;

    @Schema(description = "生效日期类型为固定日期时的开始时间")
    private LocalDateTime validStartTime;

    @Schema(description = "生效日期类型为固定日期时的结束时间")
    private LocalDateTime validEndTime;

    @Schema(description = "生效日期类型为领取日期的开始天数")
    private Integer fixedStartTerm;

    @Schema(description = "生效日期类型为领取日期的结束天数")
    private Integer fixedEndTerm;

    @Schema(description = "优惠类型：1-折扣，2-减价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer discountType;

    @Schema(description = "优惠类型为折扣时的折扣比例，例如 90 = 90%", example = "90")
    @Percent
    private Integer discountPercent;

    @Schema(description = "优惠类型为折扣时的折扣上限，单位：分", example = "100")
    private Integer discountLimitPrice;

    @Schema(description = "优惠类型为减价时的金额，单位：分", example = "100")
    private Integer discountPrice;

    @Schema(description = "产品范围", example = "1")
    private Integer productScope;

    @Schema(description = "产品范围编号的数组")
    private List<Long> productScopeValues;

    @Schema(description = "是否已领取", example = "false")
    @JsonProperty("isReceive")
    private Boolean isReceive;

    @SuppressWarnings("unused")
    public String getDiscountLimitPriceYuan() {
        return MoneyUtils.fenToYuanStr(NumberUtil.nullToZero(discountLimitPrice));
    }

    @SuppressWarnings("unused")
    public String getDiscountPriceYuan() {
        return MoneyUtils.fenToYuanStr(NumberUtil.nullToZero(discountPrice));
    }

}
